import React from 'react'
import { useLocation,useNavigate } from 'react-router-dom'
function LySw({children}) {
    function NewCap(){
        const navigate=useNavigate()
        const {pathName}=useLocation()

        const token=localStorage.getItem("token")

        const whileList=['/','*']

       if(!token && !whileList.includes[pathName]){
            navigate("/login")
       }
       return children
    }

  return <NewCap></NewCap>
}

export default LySw
